$('.btn-del').on('click', function(){
  $(this).parent().remove()
})

$(document).on('mousedown', function(e){
  var pop = $('.handle')
  if(!pop.is(e.target) && pop.has(e.target).length === 0){
    $('.handle').hide();
    $(".item .active").removeClass('active')
  }
})
$('.wk-box .item ').on('click', function(){
  var that = $(this)
  if (!that.hasClass('active')) {
    $('.item ').removeClass('active')
    that.addClass('active')
    that.children().eq(0).append($('.handle').show())
  }
  console.log('活动元素对象：')
  console.log($(".active"))
})

$('.switch-btn').on('click', function(){
  var that = $(this)
  var word = that.parent()
  word.toggleClass('word-autoh')
  if (word.hasClass('word-autoh')) {
    that.text('收起')
  } else {
    that.text('展开')
  }
})

$('.btn-group .btn').on('click', function(){
  var that = $(this)
  if (!that.hasClass('active')) {
    that.siblings().removeClass('active')
    that.addClass('active')
  }
})


$('.typeset-btn-lr, .typeset-btn-ud').on('click', function(){
  var that = $(this)
  var clas = 'i1d6 i2d6 i3d6 i4d6 i5d6'
  if (that.hasClass('typeset-btn-ud')) {
    $('.item .hd, .item .bd').removeClass(clas).addClass('i6d6')
  } else {
    $('.item .hd').removeClass(clas).addClass('i2d6')
    $('.item .bd').removeClass(clas).addClass('i4d6')
  }
})

$('.settingTextMl a').on('click', function(){
  var that = $(this)
  var ml =  that.attr('data-ml')
  console.log(ml)
  var cls = 'i6d6'
  switch (ml) {
    case 'ml1':
    cls = 'i5d6'
    break
    case 'ml2':
    cls = 'i4d6'
    break
    case 'ml3':
    cls = 'i3d6'
    break
    case 'ml4':
    cls = 'i2d6'
    break
    case 'ml5':
    cls = 'i1d6'
    break
    default:
    cls = 'i6d6'
  }
  $('.item[data-type="word"]').children().attr('class', ml + ' ' + cls)
})


$('.pop .close').on('click', function(){
  $('.mask').fadeOut(200)
  $(this).parents('.pop').fadeOut(200)
})

function dalert(tit, content) {
  $('.mask, .alert').fadeIn(200)
  $('.alert .tit').text(tit)
  $('.alert .con').html(content)
}

//dalert('保存成功！', '立即前往 <a class="btn btn-primary" href="#">流程编辑</a>')
//$('.mask, .save').fadeIn(200)